/*
    1）按视频所述方法，分别用get和post，把浏览器中购物车数据传到服务器，并用console.log打印出来
    2）服务器得到数据后，写入目录：用户名/cart.txt

*/

//get
const http = require('http')
const url = require('url')

function startServer4(route, handle) {
    var onRequest = function(request, response) {
        var pathname = url.parse(request.url).pathname;
        console.log('recive' + pathname);
        var params = url.parse(request.url, true).query
        route(handle, pathname, response, params)
    }
    var server = http.createServer(onRequest)
    server.listen(3030, '127.0.0.1')
    console.log('start on http://127.0.0.1:3030');
}

module.exports.startServer4 = startServer4